import csv

save = []
identifier = "Z02180400000120T000008T4275.csv"
source = "source/" + identifier
target = "去重后的数据/" + identifier


def read():
    # 以读方式打开文件
    with open(source, mode="r", encoding="utf-8-sig") as f:
        reader = csv.reader(f)
        # 去除首部字段名
        header = next(reader)
        save.append(header)
        lastMoment = next(reader)
        total = float(lastMoment[1])
        number = 1
        for row in reader:
            pass

    print(save)


def write():
    csvFile = open(target, 'w', encoding="utf-8-sig", newline='')
    # 如果不加入newline='',那么每写入一行数据，就会写入一行空白。可以去掉自行验证
    with csvFile:
        writer = csv.writer(csvFile)
        # 将array按行写入
        writer.writerows(save)


if __name__ == '__main__':
    read()
    write()
